require 'factcomp_rbm'
require 'dict'

torch.setdefaulttensortype('torch.DoubleTensor')

function main()
	-- load data
	local f = torch.DiskFile('toydata.dat', 'r')
	f:binary()
		local data = f:readObject():long()
		local cwdic = f:readObject() setmetatable(cwdic, Dict_mt)
		local wdic = f:readObject() setmetatable(wdic, Dict_mt)
		local cwemb = f:readObject()
		local wemb = f:readObject()
		local sampler_storage = f:readObject()
	f:close()

	data = torch.Tensor({wdic.word2id['i'], wdic.word2id["do"]}):resize(2,1)
	print(data)
	chainlen = 1000

	local model = FactCompRBM:load_from_file('model/2.model')
	--print(model.hidbias)
	for i = 1,10 do
		local h, prob_h_v = model:sample_hidden_from_visible( data )
		local v1, _ = model:sample_visible_from_hidden( data, h, chainlen, sampler_storage )
		print(wdic.id2word[v1[{1,1}]] .. ' ' .. wdic.id2word[v1[{2,1}]])	
	end
end

main()


